/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lwjglbase;

import java.nio.FloatBuffer;
import static org.lwjgl.opengl.GL11.*;

/**
 *
 * @author andrew
 */
public class Grid {

    FloatBuffer verticesBuffer;
    int size;
    
    public Grid(int size) {
        this.size = size;
        float[] verts = new float[(size+1)*6*2];
        for (int i = 0; i < (size+1); i++) {
            verts[i*12+0] = (float)i; //x
            verts[i*12+1] = 0;//y
            verts[i*12+2] = 0;//z
            verts[i*12+3] = (float)i; //x
            verts[i*12+4] = 0;//z
            verts[i*12+5] = (float)size;//z
            verts[i*12+6] = 0; //x
            verts[i*12+7] = 0;//y
            verts[i*12+8] = (float)i;//z
            verts[i*12+9] = (float)size; //x
            verts[i*12+10] = 0;//z
            verts[i*12+11] = (float)i;//z
        }
        verticesBuffer = Utils.createFB(verts);
    }

    void draw() {
        glPushMatrix();
        glDisable(GL_TEXTURE_COORD_ARRAY);
        glDisable(GL_NORMAL_ARRAY);
        glVertexPointer(3, 0, verticesBuffer);
        glDrawArrays(GL_LINES, 0, verticesBuffer.capacity()/3);
        glPopMatrix();
        glEnable(GL_TEXTURE_COORD_ARRAY);
    }
}
